<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/content/variable.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<%@ include file="/content/head.jsp"%>
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">添加字典字段信息</h3>
                </div>
                <form id="dictionaryAdd" class="form-horizontal" role="form">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="dictionaryName" class="col-sm-2 control-label">字段名称：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="childName" class="form-control" name="childName"
                                       placeholder="字段名称">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="value" class="col-sm-2 control-label">初始值：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="value" class="form-control" name="value"
                                       placeholder="初始值">
                            </div>
                        </div>
                        <br>
                        <input type="hidden" readonly="readonly" name="parentId" value="${obj}">
                        <div class="col-md-offset-5 col-md-9">
                            <button type="submit" class="btn btn-success">确定</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
    <!-- /.row -->
</section>
<%@ include file="/content/js.jsp"%>
<script type="text/javascript">
    $(function () {
        $('#dictionaryAdd').bootstrapValidator({
            message: '此值无效',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
            	childName: {
                    message: '字段名称验证失败',
                    validators: {
                        notEmpty: {
                            message: '字段名称不能为空'
                        }
                    }
                },
                value: {
                    message: '字段值验证失败',
                    validators: {
                        notEmpty: {
                            message: '字段值不能为空'
                        },
                        numeric: {
                            message: '只能输入数字'
                        }
                    }
                },
            }
        }).on('success.form.bv', function (e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            save();
        });
    });

    function save() {
        $.post("<%=path%>/dictionary/chile_add",
            $("#dictionaryAdd").serialize()
            , function (data) {
            	if (data.missage == "success") {
              	  modalMsg("新增成功", "success");
            	    window.parent.location.reload();
            	    var index = parent.layer.getFrameIndex(window.name);
            	    parent.layer.close(index);
          	    }else if(data.missage == "userNameRepeat"){
            		 modalMsg("新增失败", "userNameRepeat");
           	    }else{
            		 modalMsg("更新失败", "error");
           	 	}
             }
        );
    }

</script>
</body>
</html>
